ActiveAdmin.register BlockFlow do
  config.per_page = [10, 30, 50, 100]
  permit_params :name, :index, :change, :in, :out, :net_amount, :count, :days, :mark, :cate_type, :is_choice

  index do
    selectable_column
    id_column
    column :name
    column :ts_code do |block_flow|
      Block.find_by_name(block_flow.name).ts_code if Block.find_by_name(block_flow.name)
    end
    column :change
    column :net_amount
    column :count
    column :mark
    column :cate_type
    column :is_choice
    column :updated_at
    column :created_at
    actions
  end

  filter :name
  filter :cate_type
  filter :mark, as: :select
  filter :is_choice
  filter :created_at, as: :date_range

  form do |f|
    f.inputs do
      f.input :name
      f.input :is_choice
    end
    f.actions
  end

  show do
    attributes_table do
      row :name
      row :change
      row :net_amount
      row :count
      row :mark
      row :cate_type
      row :is_choice
      row :updated_at
      row :created_at
      row :is_choice
    end
    div '' do

      span "rake ths:block_stock['#{Block.find_by_name(resource.name).ts_code}']"
    end
  end
end
